package td.pt.widget;

import td.pt.ui.UsabilityScaleQuestion;
import td.pt.ui.UsabilityTextQuestion;

import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.PopupViewImpl;

public class SurveyView extends PopupViewImpl implements SurveyPresenter.MyView {

	private final Widget widget;

	public interface Binder extends UiBinder<Widget, SurveyView> {
	}

	@UiField
	UsabilityScaleQuestion layout;
	@UiField
	UsabilityScaleQuestion categoryTree;
	@UiField
	UsabilityScaleQuestion tagTree;
	@UiField
	UsabilityScaleQuestion topThoughts;
	@UiField
	UsabilityScaleQuestion generalNavigation;
	@UiField
	UsabilityScaleQuestion signUpLogin;
	@UiField
	UsabilityScaleQuestion tagging;
	@UiField
	UsabilityScaleQuestion addToActiveRefs;
	@UiField
	UsabilityScaleQuestion createNewThought;
	@UiField
	UsabilityScaleQuestion addCategoryToNewThought;
	@UiField
	UsabilityScaleQuestion refsInNewThought;
	@UiField
	UsabilityScaleQuestion publish;
	@UiField
	RadioButton tableListing;
	@UiField
	RadioButton bothListings;
	@UiField
	RadioButton categoryListing;
	@UiField
	RadioButton neitherListing;
	@UiField
	UsabilityTextQuestion whyListing;
	@UiField
	UsabilityTextQuestion mostConfusing;
	@UiField
	UsabilityTextQuestion theBest;
	@UiField
	UsabilityTextQuestion overall;
	@UiField
	UsabilityTextQuestion comments;
	@UiField
	Button submit;

	@Inject
	public SurveyView(final EventBus eventBus, final Binder binder) {
		super(eventBus);
		widget = binder.createAndBindUi(this);
	}

	@Override
	public Widget asWidget() {
		return widget;
	}

	public UsabilityScaleQuestion getLayout() {
		return layout;
	}

	public UsabilityScaleQuestion getCategoryTree() {
		return categoryTree;
	}

	public Widget getWidget() {
		return widget;
	}

	public UsabilityScaleQuestion getTagTree() {
		return tagTree;
	}

	public UsabilityScaleQuestion getTopThoughts() {
		return topThoughts;
	}

	public UsabilityScaleQuestion getGeneralNavigation() {
		return generalNavigation;
	}

	public UsabilityScaleQuestion getSignUpLogin() {
		return signUpLogin;
	}

	public UsabilityScaleQuestion getTagging() {
		return tagging;
	}

	public UsabilityScaleQuestion getAddToActiveRefs() {
		return addToActiveRefs;
	}

	public UsabilityScaleQuestion getCreateNewThought() {
		return createNewThought;
	}

	public UsabilityScaleQuestion getAddCategoryToNewThought() {
		return addCategoryToNewThought;
	}

	public UsabilityScaleQuestion getRefsInNewThought() {
		return refsInNewThought;
	}

	public UsabilityScaleQuestion getPublish() {
		return publish;
	}

	public UsabilityTextQuestion getWhyListing() {
		return whyListing;
	}

	public UsabilityTextQuestion getTheBest() {
		return theBest;
	}

	public UsabilityTextQuestion getOverall() {
		return overall;
	}

	public UsabilityTextQuestion getComments() {
		return comments;
	}

	public UsabilityTextQuestion getMostConfusing() {
		return mostConfusing;
	}

	public Button getSubmit() {
		return submit;
	}

	public Integer getListing() {
		if (tableListing.getValue()) {
			return 4;
		} else if (bothListings.getValue()) {
			return 3;
		} else if (categoryListing.getValue()) {
			return 2;
		} else if (neitherListing.getValue()) {
			return 1;
		}
		return 0;
	}

}
